package com.jeesite.modules.fl.web.app;

import com.jeesite.common.entity.Page;
import com.jeesite.modules.fl.entity.Content;
import com.jeesite.modules.fl.entity.Enterprise;
import com.jeesite.modules.fl.service.ContentService;
import org.apache.shiro.authz.annotation.RequiresGuest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RequestMapping(value = "/content")
@Controller
public class AppContentController {
    @Autowired
    private ContentService contentService;
    /**
     * 前台用户查询列表数据
     */
    @RequestMapping(value = "listOwnerData")
    @ResponseBody
    public Page<Content> listOwnerData(Content content, HttpServletRequest request, HttpServletResponse response) {
        content.setFilterOwner("1");
        Page<Content> page = contentService.findPage(new Page<Content>(request, response), content);
        //获取列表里清除内容
        for (Content item : page.getList()){
            item.setContent(null);
        }
        return page;
    }

    /**
     * 前台用户查询列表数据
     */
    @RequestMapping(value = "")
    @ResponseBody
    public Content get(@RequestParam(value="id", required=false)String id){
        return contentService.appView(id);
    }
}
